'''
Created on Mar 24, 2010

@author: jhlee
'''
import math

class Vertex3D:
    def __init__(self,x=0,y=0,z=0):
        self.x = x
        self.y = y
        self.z = z
    
    def set(self,x,y,z):
        self.x = x
        self.y = y 
        self.z = z
            
    def clone(self):
        return Vertex3D(self.x, self.y, self.z)
    
    def minus(self, rhs):
        self.x = self.x - rhs.x
        self.y = self.y - rhs.y
        self.z = self.y - rhs.z
        
    def normalize(self):
        v = math.sqrt(self.x*self.x + self.y*self.y + self.z*self.z)
        self.x = self.x / v
        self.y = self.y / v
        self.z = self.z / v
        
        
    def cross(w,v,out=None):
        if out is None:
            out = Vertex3D()
            
        out.set((w.y * v.z) - (w.z * v.y), (w.z * v.x) - (w.x * v.z), (w.x * v.y) - (w.y * v.x))
        return out
    